function randomNum(minNum, maxNum) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * minNum + 1, 10);
        case 2:
            return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
        default:
            return 0;
    }
}

function handExamQuestionFmt(content) {

    if (!content) {
        return "";
    }
    content = content.split("##").join("【");
    content = content.split("$$").join("】");
    content = content.split("***").join("");
    content = content.split("<img").join("< img style='vertical-align:middle;'");
    return content;
}

function resetTime(time) {
    var timer = null;
    var t = time;
    var m = 0;
    var s = 0;
    m = Math.floor(t / 60 % 60);
    m < 10 && (m = '0' + m);
    s = Math.floor(t % 60);

    function countDown() {
        s -= 5;
        // s < 10 && (s = '0' + s);
        if (s.length >= 3) {
            s = 59;
            m = "0" + (Number(m) - 1);
        }
        if (m.length >= 3) {
            m = '00';
            s = '00';
            clearInterval(timer);
        }
        if (s !== 0) console.log('距离上传:' + s + "秒");
        else console.log('又开始了新的倒计时');
    }

    return timer = setInterval(countDown, 5000);
}


function sliceArray(array, size) {
    let result = [];
    for (let x = 0; x < Math.ceil(array.length / size); x++) {
        let start = x * size;
        let end = start + size;
        result.push(array.slice(start, end));
    }
    return result;
}

export {
    randomNum,
    handExamQuestionFmt,
    resetTime,
    sliceArray
}
